# -*- python -*-
#:kivy 1.0
#:import guiCommon levin.guiCommon
#:import levinCommon levin.levinCommon

#: set fontSize 12
<DisplayLabel>:
    maxHeight: 50
    color: [0.533, 0.031, 0.024, 1.] 
    halign: 'center'
    valign: 'middle'

<WineDetailKeys>:
    font_size: row_font_size-2
    
<WineDisplay>:
    orientation: 'vertical'
    detailsBox: _detailsBox
    mainWidgets: [_appellation_lab, _cru_lab] #, _millesime_lab]
    buttonBar: _buttonBar
    topBox: _upbox

    spacing: int(root.width*0.01)
    ## image_src: 'icons/nopic.png'
    
    BoxLayout:
        id: _upbox
        size_hint: (1,None)
        orientation: 'vertical'
        height: _appellation_lab.height +_cru_lab.height+ _image.height +self.padding[0]*2
        x: root.x
        y: root.top - self.height

        ## canvas:            
        ##     BorderImage:
        ##         source: 'data/toto2.png'
        ##         #border: 16, 16, 16, 16
        ##         border: 27,27,27,27
        ##         pos: self.pos
        ##         size: self.size
        ##         ## pos: (self.x+100,self.y+100)
        ##         ## size: (120,120)

        DisplayLabel:
            id: _appellation_lab
            #text: root.bottle.appellation if root.bottle else ''
            font_size: 20
            color: purple
            bold: True
        DisplayLabel: 
            id: _cru_lab                 
            #text: root.bottle.cru_name if root.bottle else ''
            font_size: fontSize+2
        Image:
            id: _image
            source: root.image_src
            size_hint: (1,None)
            center_x: root.center_x
            height: min(self.texture.height if self.texture else 0, 0.4*root.height)
            #text: _('Add picture')
        ## DisplayLabel:
        ##     id: _millesime_lab                                   
        ##     #text: str(root.bottle.millesime) if root.bottle else ''
        ##     font_size: fontSize+2
            
    BoxLayout:
        orientation: 'vertical'
        id: _detailsBox
        pos: (root.x, _buttonBar.y+_buttonBar.height+root.spacing)
        size_hint: (1,None)
        size: (root.width, root.height - _upbox.height - _buttonBar.height - _buttonBar2.height-2*root.spacing)
            
    LeVinButtonBar:
        padding: root.spacing
        spacing: root.spacing
        id: _buttonBar
        size_hint: (1, None)
        pos: (root.x, root.y+_buttonBar2.height + root.spacing)
        LeVinButton:
            icon_src: 'icons/suppress.png'
            text: _('Suppress')
            on_press: guiCommon.commonEvents.dispatch('on_delete_bottle',root.bottle)   if root.bottle else None
        LeVinButton:
            icon_src: 'icons/edit.png'
            text: _('Edit')
            on_press: guiCommon.commonEvents.dispatch('on_start_edit_bottle',root.bottle) if root.bottle else None
        LeVinButton:
            icon_src: 'icons/drinkBottle.png'
            text: _('1 drunk')
            on_press: guiCommon.commonEvents.dispatch('on_start_edit_tasting',root.bottle, True) if root.bottle else None            
    LeVinButtonBar:
        padding: root.spacing
        spacing: root.spacing
        id: _buttonBar2
        size_hint: (1, None)
        pos: (root.x, root.y)
        LeVinButton:
            text: _('Add Pic')
            icon_src: 'icons/add_pic.png'
            on_press: root.start_add_image()
        LeVinButton:
            icon_src: 'icons/Hyperlink-internet-search.png'            
            text: _('Search web')
            on_press: levinCommon.webSearchBottle(root.bottle)
        LeVinButton:
            text: _('Recommand')
            #on_press: guiCommon.commonEvents.dispatch('on_start_edit_tasting',root.bottle, True) if root.bottle else None            
